home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
CLPMOUSE.ARJ
/
MENUTO.PRG
< prev
next >
Wrap
Text File
|
1991-06-17
|
4KB
|
145 lines
/*-----------------------*/
/* Mouse functions */
/* MENU TO replacement */
/*-----------------------*/
/* MENU TO - This function replaces the MENU TO function for CLIPPER 5.0 / 5.1
Replacement is accomplished by using the functions below as specd
MPROMPT(expC) - Adds the prompt at the corresponding window
location, beginning at 1.
MMENUTO(expN, expC)
- Resets the prompts if expN = 0
- Begins the prompting
- double-click or <enter> on correct one
- colorization by expC
*/
FUNCTION MPROMPT(string)
aadd(menuto_ARR,string)
FUNCTION MMENUTO(exp1,pmcolor)
local pt,x,y,x1,y1,leng,sx,set_disp,old_position,cur_position,mbut,mkey,loc
local ax,ay,ab,wx
if exp1 = 0
public menuto_ARR
menuto_ARR = array(0)
return(NIL)
endif
/* get window coordinates */
fseek(winhndl,0)
fvbl = val(freadstr(winhndl,10))
fseek(winhndl,fvbl-4)
vblen = val(freadstr(winhndl,4))
fseek(winhndl,-1*(vblen+4),1)
ptr = fseek(winhndl,0,1)
pt = freadstr(winhndl,vblen)
x = val(subs(pt,1,2))
y = val(subs(pt,4,2))
x1 = val(subs(pt,7,2))
y1 = val(subs(pt,10,2))
pt = subs(pt,13)
/* put in array information */
leng = (y1-y) - 2
for sx = 1 to len(menuto_ARR)
if x+sx < x1
@ x+(sx),y+1 say subs(menuto_ARR[sx],1,leng)
endif
next
set_disp = .t.
old_position = 1
cur_position = 1
do while .t.
mbut=SMOUSE(x,y,x1-1,y1-2,1,3)
mkey = inkey()
if mkey<>0.or.mbut<>NIL
do case
case mkey = 1
set_disp = .t.
cur_position = 1
case mkey = 6
set_disp = .t.
cur_position = len(menuto_ARR)
case mkey > 47 .and. mkey < 128
loc = 0
for n = 1 to len(menuto_ARR)
if subs(menuto_ARR[n],1,1) = chr(mkey)
loc = n
keyboard(chr(13)+chr(13))
endif
next
if loc <> 0
set_disp = .t.
cur_position = loc
endif
case mkey = 27
return(0)
case mkey = 5 .or. mkey = 19
set_disp = .t.
cur_position = cur_position-1
if cur_position < 1
if set(35)
cur_position = len(menuto_ARR)
else
cur_position = 1
endif
endif
case mkey = 24 .or. mkey = 4
set_disp = .t.
cur_position = cur_position+1
if cur_position > len(menuto_ARR)
if set(35)
cur_position = 1
else
cur_position = len(menuto_ARR)
endif
endif
case mkey = 13 .or. mkey = 18 .or. mkey = 3
return(cur_position)
case mbut <> NIL
ax = val(subs(mbut,1,2))
ay = val(subs(mbut,3,2))
ab = val(subs(mbut,5))
wx = (ax-x)
set_disp = .t.
if wx < 1
wx = 1
if old_position = wx
set_disp = .f.
endif
endif
if wx > len(menuto_ARR)
wx = len(menuto_ARR)
if old_position = wx
set_disp = .f.
endif
endif
if wx = old_position
return(cur_position)
endif
cur_position = wx
endcase
endif
if set_disp = .t.
@ x+(old_position),y+1 say subs(menuto_ARR[old_position],1,leng)
ocolor=setcolor()
setcolor(pmcolor)
@ x+(cur_position),y+1 say subs(menuto_ARR[cur_position],1,leng)
setcolor(ocolor)
old_position = cur_position
set_disp = .f.
if mbut <> nil
mbut = nil
inkey(.20) /* allow button release for double click! */
endif
endif
enddo